package com.chen.service.impl;

import com.chen.dao.BookMapper;
import com.chen.entity.Book;
import com.chen.service.BookService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {
    @Autowired
    BookMapper bookMapper;

    @Override
    public List<Book> selectAll() {
        List<Book> books = bookMapper.selectAll();
        return books;
    }

    @Override
    public PageInfo<Book> getPage(Integer pageNum) {
        PageHelper.startPage(pageNum, 3, "id desc");
        List<Book> books = bookMapper.selectAll();
        PageInfo<Book> page = new PageInfo<>(books);
        return page;
    }

    @Override
    public void del(Integer[] ids) {
        bookMapper.deleteByNums(ids);
    }
}
